package com.winchain.chainbill.tbill.biz.rx;

import com.shell.bee.base.utils.StringUtil;
import com.shell.bee.invoince.service.InvBasService;
import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.bill.base.dao.CbAttDao;
import com.winchain.chainbill.bill.base.po.CbAtt;
import com.winchain.chainbill.tbill.base.po.TbDct;
import com.winchain.chainbill.tbill.base.po.TbRec;
import com.winchain.chainbill.tbill.biz.TBill;
import com.winchain.chainbill.tbill.biz.TBillEvent;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TBillRjctUpdateAttSubscriber extends OnErrorNotImplementedSubscriber<TBillEvent<TbDct>> {
	@Autowired
	private CbAttDao cbAttDao;
	@Autowired
	private InvBasService invBasService;

	public void onApplicationEvent(TBillEvent<TbDct> t) {
		TbRec record = t.getBill().getRec();
		TbDct tbDct = (TbDct) t.getBill().getSource();
		if (!StringUtil.emptyAndNull(tbDct.getDctId())) {
			List<CbAtt> cbAtts = this.cbAttDao.selectDelCbAtt(tbDct.getDctId(), record.getBillId(), "11", null);
			for (CbAtt cbAtt : cbAtts) {
				this.invBasService.updateInvBlc(cbAtt.getAttId(), "5");
			}
		}
	}
}
